package com.hpf.lease.web.admin.controller;

import com.hpf.lease.common.result.Result;
import com.hpf.lease.model.bean.FeeKey;
import com.hpf.lease.web.admin.vo.FeeInfoVo;
import com.hpf.lease.web.admin.service.FeeKeyService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/fee")
@Tag(name = "房间的杂费的键管理")
public class FeeKeyInfoController {
    @Resource
    FeeKeyService feeKeyService;
    @PostMapping("/key/saveOrUpdate")
    @Operation(summary = "根据id添加或修改房杂费的键")
    public Result<Object> saveOrUpdate(@RequestBody FeeKey feeKey){
        return Result.build(feeKeyService.saveOrUpdateInfo(feeKey));
    }
    @GetMapping("/list")
    @Operation(summary = "查询所有")
    public Result<List<FeeInfoVo>> selectAll(){
        List<FeeInfoVo> list = feeKeyService.selectAll();
        return Result.ok(list);
    }
    @DeleteMapping("/key/deleteById")
    @Operation(summary = "根据id删除房杂费的键")
    public Result<Object> deleteById(@RequestParam Long feeKeyId){
        return Result.build(feeKeyService.removeById(feeKeyId));
    }

}
